package model

type Product struct {
	Id            int             `gorm:"column:id;primary_key;AUTO_INCREMENT" form:"id" json:"id"`
	UserId        int             `gorm:"column:user_id" form:"userId" json:"userId"`
	ProductType   string          `gorm:"column:product_type" form:"productType" json:"productType"`
	Nation        string          `gorm:"column:nation" form:"nation" json:"nation" binding:"required"`
	Company       string          `gorm:"column:company" form:"company" json:"company"`
	FactoryNo     string          `gorm:"column:factory_no" form:"factoryNo" json:"factoryNo" binding:"required"`
	ProductName   string          `gorm:"column:product_name" form:"productName" json:"productName" binding:"required"`
	ProductNo     string          `gorm:"column:product_no" form:"productNo" json:"productNo"`
	Specification string          `gorm:"column:specification" form:"specification" json:"specification"`
	PriceTrend    string          `gorm:"column:price_trend" form:"priceTrend" json:"priceTrend"`
	Remark        string          `gorm:"column:remark" form:"remark" json:"remark"`
	Detail        string          `gorm:"column:detail" form:"detail" json:"detail"`
	FileInfo      []FileInfo      `gorm:"ForeignKey:Identification;AssociationForeignKey:Id" json:"imageList"`
	ProductDetail []ProductDetail `gorm:"ForeignKey:ProductInfoId;AssociationForeignKey:Id" format:"productDetailList" json:"productDetail"`
}

type ProductDetail struct {
	Id            int        `gorm:"column:id;primary_key;AUTO_INCREMENT" form:"id" json:"id"`
	UserId        int        `gorm:"column:user_id" form:"userId" json:"userId"`
	ProductDate   string     `gorm:"column:product_date" form:"productDate" json:"productDate"`
	ProductBatch  string     `gorm:"column:product_batch" form:"productBatch" json:"productBatch"`
	Remark        string     `gorm:"column:remark" form:"remark" json:"remark"`
	Images        string     `gorm:"column:files" form:"files" json:"-" `
	ProductInfoId int        `gorm:"product_info_id" form:"productInfoId" json:"productInfoId" binding:"required"`
	FileInfo      []FileInfo `gorm:"ForeignKey:Identification;references:ProductInfoId" json:"imageList"`
}
